<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>01-逛水果店</title>

    <style>
        div {
            margin: 50px;
            padding: 20px;
            border: 1px solid #ccc;
            text-align: center;
        }

        table {
            width: 100%;
            margin-top: 5px;
            border: 1px solid #ccc;
        }

        tr {
            height: 30px;
        }

        td,
        th {
            border: 1px solid #808080;
        }
    </style>
</head>

<body>
    <div id="app">
        欢迎光临_vue_开发的收银系统_水果店
        <table>
            <tr>
                <th>
                    苹果 10 ¥ /斤，折扣 < 8 折>
                </th>
            </tr>
            <tr>
                <td>
                    请输入你要购买的斤数
                    <input type="number"  v-model="num" min="0">
                </td>
            </tr>
            <tr>
                <td>
                    <button @click="calcPrice">结账买单~</button>
                </td>
            </tr>
            <tr>
                <td>
                    结账单: 总价: {{ price }} ¥元 折后价: {{ price * 0.8 }} ¥元 省了: {{ price * 0.2 }} ¥元
                </td>
            </tr>
        </table>
    </div>

    <script src="../vue.js"></script>
    <script>
        const app = new Vue({
            el: '#app',
            data: {
                num: 0,
                price: 0,
            },
            methods: {
                calcPrice() {
                    this.price = 10 * this.num
                }
            }
        })
    </script>

</body>

</html>